//
//  UserInfoModel.m
//  MooreDoll
//
//  Created by 郭景豪 on 2014/12/23.
//  Copyright (c) 2014年 Tank. All rights reserved.
//

#import "UserInfoModel.h"


@implementation UserInfoModel

@synthesize ImagePath,NICKNAME,JID,PhoneNumber;
+(UserInfoModel *)sharedInstance
{
    static UserInfoModel *userInfo;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        userInfo = [[UserInfoModel alloc] init];

    });
    return userInfo;
}

-(UserInfoModel *)setDataWithName:(NSString *)aNICKNAME andImagePath:(NSString *)aImagePath andPhoneNumber:(NSString *)aPhoneNumber andJID:(NSString *)aJID
{
    NICKNAME =[ aNICKNAME ? aNICKNAME : NICKNAME stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    ImagePath = aImagePath ? aImagePath : ImagePath;
    
    PhoneNumber = aPhoneNumber ? aPhoneNumber : PhoneNumber;
    
    JID = aJID ? aJID : JID;
    
    return self;
}

-(void)setPhoneNumber:(NSString *)aPhoneNumber
{
    PhoneNumber = aPhoneNumber;

    [UserDefaults set:PhoneNumber withKey:@"PhoneNumber"];

}

-(void)setJID:(NSString *)aJID
{
    NSArray *array = [aJID componentsSeparatedByString:@"@"];
    JID = array[0];
    
    [UserDefaults set:JID withKey:@"userJIDnoDomain"];
    
}

-(void)setNICKNAME:(NSString *)aNICKNAME
{
    NICKNAME = aNICKNAME;
    
    
    [UserDefaults set:ImagePath withKey:@"NICKNAME"];
   

}

-(void)setImagePath:(NSString *)aImagePath
{
    ImagePath = aImagePath;
    
    [UserDefaults set:ImagePath withKey:@"userImage"];

}
@end
